copying the Paragraph Style attribute into another attribute

I posted the same thread on the RPE forums, but this forum might be a better place
https://www.ibm.com/developerworks/forums/thread.jspa?threadID=378243

We have a template that looks at an object-level DOORS attribute called "Style", and whatever value it is, that is the style from the Word stylesheet that it tries to use.

When you import a document from Word, it puts the style for the particular paragraph into the "Paragraph Style" attribute. This value has some encoding to it, for example, "<Object Heading:Heading 1>" or "<Object Text:Normal>".

Does anyone have a DXL script that will copy just the style name from "Paragraph Style" and place it into another attribute?

Any help is appreciated!

-Dan
DanMott - Thu Jul 21 15:36:47 EDT 2011

Re: copying the Paragraph Style attribute into another attribute
PDU - Fri Jul 22 02:02:59 EDT 2011

Hi,

if you create this new attribut as DXL, you can use :


obj.attrDXLName = richTextWithOle obj.
"Paragraph Style"


Pierre

Re: copying the Paragraph Style attribute into another attribute
DanMott - Fri Jul 22 11:25:22 EDT 2011

PDU - Fri Jul 22 02:02:59 EDT 2011
Hi,

if you create this new attribut as DXL, you can use :


obj.attrDXLName = richTextWithOle obj.
"Paragraph Style"


Pierre

That will give me the same text as Paragraph Style, I am looking for just the Style name.

For example,

If "Paragraph Style" == "<Object Heading:Heading 1>" then "Style" == "Heading 1"

Thoughts?

-Dan

Re: copying the Paragraph Style attribute into another attribute
llandale - Fri Jul 22 16:07:42 EDT 2011

DanMott - Fri Jul 22 11:25:22 EDT 2011
That will give me the same text as Paragraph Style, I am looking for just the Style name.

For example,

If "Paragraph Style" == "<Object Heading:Heading 1>" then "Style" == "Heading 1"

Thoughts?

-Dan

This will get you going:

string Re_String = 
"^(<Object )(Heading|Text)(:)(.*)(>)$" Regexp reValidStyle = regexp2(Re_String)   

void   Check(string ParaStyle) 
{   string  Style 

if (reValidStyle ParaStyle) 
{  Style = ParaStyle[match 4] print  
"true\t[" ParaStyle 
"]\t["Style 
"]\n" 
} 

else 
{  print  
"false\t[" ParaStyle 
"]\t["
"]\n" 
} 
} print Re_String 
"\n" Check(
"<Object Heading:Heading 1>") Check(
"<Object Text:Normal>") delete(reValidStyle)

  • Louie

Re: copying the Paragraph Style attribute into another attribute
DanMott - Fri Jul 22 16:43:02 EDT 2011

llandale - Fri Jul 22 16:07:42 EDT 2011
This will get you going:


string Re_String = 
"^(<Object )(Heading|Text)(:)(.*)(>)$" Regexp reValidStyle = regexp2(Re_String)   

void   Check(string ParaStyle) 
{   string  Style 

if (reValidStyle ParaStyle) 
{  Style = ParaStyle[match 4] print  
"true\t[" ParaStyle 
"]\t["Style 
"]\n" 
} 

else 
{  print  
"false\t[" ParaStyle 
"]\t["
"]\n" 
} 
} print Re_String 
"\n" Check(
"<Object Heading:Heading 1>") Check(
"<Object Text:Normal>") delete(reValidStyle)

  • Louie

Thanks, I used that as a starting point and came up with a solution that works for me, so we can mark this answered:

string Re_String = "(:)(.*)(>)$"
Regexp reValidStyle = regexp2(Re_String)

string parseStyle(string ParaStyle, Object o)
{
string str = ""
if (reValidStyle ParaStyle)
{
str = ParaStylematch 2
}

return str
}

Object o

for o in current Module do {
string paraStyle = o."Paragraph Style"
string styleStr = parseStyle(paraStyle,o)
Style = styleStr
}

delete(reValidStyle)